<template>
    <div class="all">
        <p class="title"># 全部 </p>
        <div class="all_moves">
            <div class="all_move" v-for="(v_all,index) in videos" :key="index" @click="playVideo(v_all)">
                <div class="move">
                    <p @mouseenter="downSynopsis()" @mouseleave="upSynopsis()">简介</p>
                    <div class="all_mask" @mouseenter="downSynopsis()" @mouseleave="upSynopsis()">
                        <div class="description">&nbsp;&nbsp;</div>
                    </div>
                    <img :src="file_path+v_all.videoCoverPic" @mouseenter="show_mask(1)">
                </div>
                <div class="all_info">
                    <p class="all_title">{{v_all.videoTitle}}</p>
                    <p class="all_author">作者：{{v_all.videoAuthor}}</p>
                </div>
                
                <div class="move_mask" @mouseenter="show_mask(1)" @mouseleave="hide_mask()">
                    <img class="play" src="/static/images/play.png">
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import video_url from './url'
import file_path from './file_url'

export default {
    data(){
        return{
            url: video_url[1].url,
            file_path: file_path[0],
            all_array: [],
            videos:[]
        }
    },
    methods:{
        downSynopsis(){
            let title_init_element = event.target.parentNode.children[3];
            let mask_element = event.target.parentNode.children[1];

            $(title_init_element).stop().hide();
            $(mask_element).stop().slideDown(200);
        },
        upSynopsis(){
            let title_init_element = event.target.parentNode.children[3];
            let mask_element = event.target.parentNode.children[1];

            $(mask_element).stop().slideUp(200);
            $(title_init_element).stop().show();
        },
        show_mask(flag){
            let title_init_element = event.target.parentNode.parentNode.lastChild;
            let play_element = event.target.parentNode.children[2];
            if(flag == 1){
                for(let i=0; i<this.all_array.length; i++){
                    if(this.all_array[i].lastChild != title_init_element){
                        $(this.all_array[i].lastChild).stop().fadeOut(300);
                    }
                }
            }else if(flag == 2){
                for(let i=0; i<this.type1_array.length; i++){
                    if(this.type1_array[i].lastChild != title_init_element){
                        $(this.type1_array[i].lastChild).stop().fadeOut(300);
                    }
                }
            }
            
            $(title_init_element).stop().fadeIn(300);
            $(play_element).stop().fadeIn(350);
        },
        hide_mask(){
            let title_init_element = event.target.parentNode.lastChild;
            let play_element = event.target.parentNode.children[2];
            $(title_init_element).stop().fadeOut(300);
            $(play_element).stop().fadeOut(350);
        },
        playVideo(video){
            const { href } = this.$router.resolve({
                path:"/playVideo",
                query:{
                    id: video.id,
                }
			});
			window.open(href, '_blank');
        },
    },
    created(){
        this.$axios({
            url: this.url,
        }).then(res => {
            this.videos = res.data;
        })
    },
    mounted(){
        // 先给页面注册滚动事件
        document.addEventListener('scroll',this.scroll, true)
        this.all_array = $(".classification .all .all_moves .all_move");
    }
}
</script>

<style scoped>
    *{
        margin: 0;
        padding: 0;
        list-style: none;
    }
    /* 分类 */
    .classification{
        width: 1368px;
        height: 1500px;
        /* border: 1px solid green; */
        margin-left: 5%;
        margin-bottom: 30px;
    }
    /* 全部（all） */
    .classification .all{
        width: 1368px;
        height: 550px;
        /* background-color: red; */
    }
    .classification .title{
        width: 90%;
        height: 50px;
        /* background-color: skyblue; */
        margin-left: 4%;
        padding-left: 1%;
        margin-top: 10px;

        font-size: 25px;
        line-height: 50px;
        font-weight: bold;
        letter-spacing: 1px;
        color: #409eff;
        border-bottom: 2px solid #ddd;
    }
    .classification .all .all_moves{
        width: 1220px;
        height: 450px;
        margin-left: 5%;
        margin-top: 20px;
        /* background-color: skyblue; */
    }
    .classification .all .all_moves .all_move{
        position: relative;
        width: 200px;
        height: 200px;
        float: left;
        margin-top: 20px;
        margin-left: 35px;
        /* background-color: green; */
    }
    .classification .all .all_moves .all_move .move img{
        width: 190px;
        height: 130px;
        margin-left: 5px;
        margin-top: 0px;
        cursor: pointer;
    }
    .classification .all .all_moves .all_move .move .all_mask{
        position: absolute;
        display: none;
        width: 190px;
        height: 130px;
        background-color: #333;
        opacity: .8;
        z-index: 5;
        top: 0;
        left: 5px;
    }
    .classification .all .all_moves .all_move .move p{
        width: 190px;
        height: 20px;
        background-color: #333;
        opacity: .95;
        color: rgb(255, 255, 255);
        border-radius: 3px;
        margin-top: -20px;
        margin-left: 5px;
        cursor: pointer;

        font-size: 14px;
        text-align: center;
        line-height: 20px;
        letter-spacing: 5px;
    }
    .classification .all .all_moves .all_move .move .description{
        width: 150px;
        height:100px;
        margin-left: 15px;
        border-radius: 0.5rem;
        line-height: 19px;
        user-select: none;
        padding: 6px 5px;
        font-size: 12px;
        font-weight: bold;
        letter-spacing: 1px;
        color: #fff;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 5;
        -webkit-box-orient: vertical;
    }
    .classification .all .all_moves .all_move .all_info{
        width: 190px;
        height: 60px;
        margin-left: 5px;
        /* background-color: red; */
    }
    .classification .all .all_moves .all_move .all_info .all_title{
        position: absolute;
        width: 175px;
        height: 40px;
        padding-left: 5px;
        padding-right: 5px;

        font-size: 15px;
        line-height: 20px;
        color: #333;
        z-index: 5;

        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    .classification .all .all_moves .all_move .all_info .all_author{
        position: absolute;
        width: 175px;
        height: 20px;
        bottom: 5px;
        margin-left: 5px;
        padding-top: 5px;
        font-size: 10px;
        line-height: 20px;
        color: #999;
    }
    .classification .all .all_moves .all_move .move_mask .play{
        position: absolute;
        left: 80px;
        top: 50px;
        width: 30px;
        height: 30px;
        cursor: pointer;
        z-index: 6;
    }
    .classification .all .all_moves .all_move .move_mask{
        display: none;
        position: absolute;
        left: 0;
        top: 0;
        width: 190px;
        height: 130px;
        margin-left: 5px;
        cursor: pointer;
        background: rgba(51, 51, 51,.5)
    }
</style>